<template>
	<view class="universe">
		<view class="bg">
			<image src="../../static/yz3.png" class="bg_img"></image>
			<view class="tab">
				<u-tabs :list="circleTabList" @change="selectCircleTab" class="tabs" :activeStyle="{color:'#fff'}"
					:inactiveStyle="{color:'#fff'}"></u-tabs>
			</view>
			<view class="sea">
				<view class="search">
					<!-- <image src="../../static/search.png" mode=""></image> -->
					<input class="sea_ipt" type="text" @input="kwinput" placeholder="AI智能" v-model="keyword">
					<view class="btn" @click="search">
						搜索
					</view>
				</view>
			</view>
			<view class="rw">
				<image src="../../static/yz.png" class="rw_img"></image>
			</view>
		</view>
		<view v-for="(item, index) in circleList" :key="index">
			<view @click="addDiscuss(item.id)">
				<view class="flx">
					<view class="tabicon">
						<image :src="item.avatar" mode="" class="icon_img"></image>
					</view>
					<view class="txt_fx1">
						<view class="mgb-20">
							<text class="txt">{{item.nickName}}</text>
							<text class="btn"
								@click.stop="addFollow(item)">{{!item.isFollow || item.isFollow == 0?'+关注':'-取消关注'}}</text>
						</view>
						<!-- <image src="../../static/xsss.png" class="shan"></image> -->
						<!-- <view class="fx111">
							<view class="mgb-20">
								<text class="txt">{{item.txt}}</text>
								<text class="btn">+关注</text>
							</view> -->
						<!-- <image src="../../static/组 42@2x.png" class="shan"></image> -->
						<!-- <image src="../../static/xsss.png" class="shan"></image>
						</view> -->
						<!-- <view class="flx1">
							<view class="sltxt">关注{{item.sta_follow_count}}</view>
							<view class="sltxt">帖子{{item.sta_circle_count}}</view>
						</view> -->
					</view>
				</view>
				<view class="head">
					<view class="headtxt">{{item.title}}</view>
					<view class="nrtxt">{{item.content}}</view>
					<view>
						<image v-for="(item,index) in item.pigList" :src="item" class="con_tu" mode=""></image>
					</view>
					<view class="flx2">
						<view class="smtxt1">{{item.diffTime}}</view>
						<!--分享-->
						<!-- <view class="imgtb">
							<image src="../../static/s66.png" class="tb"></image>
							<text class="smtxt">111111</text>
						</view> -->
						<!--点赞-->
						<view @click.stop="addLikes(item.id)">
							<image src="../../static/xss.png" class="tb"></image>
							<text class="smtxt">{{item.likesCount}}</text>
						</view>
						<!--评论-->
						<view @click="addDiscuss(item.id)">
							<image src="../../static/discuss.png" class="tb"></image>
							<text class="smtxt">{{item.discussCount}}</text>
						</view>
					</view>
				</view>
			</view>
			<!-- <view class="line"></view> -->
		</view>
		<view class="pos" @click="iss">
			<view>
				<image src="../../static/s55.png" class="ft"></image>
			</view>
		</view>
	</view>
	<tabBar></tabBar>
</template>

<script>
	export default {
		data() {
			return {
				keyword: '',
				iffollow: '',
				ifecommend: '',
				ifhot: '',
				circleTabList: [{
					name: '最新',
					iffollow: '', //是否关注
					ifecommend: '', //是否推荐
					ifhot: '' //是否热门
				}, {
					name: '关注',
					iffollow: 1, //是否关注
					ifecommend: 0, //是否推荐
					ifhot: 0 //是否热门
				}, {
					name: '推荐',
					iffollow: 0, //是否关注
					ifecommend: 1, //是否推荐
					ifhot: 0 //是否热门

				}, {
					name: '热门',
					iffollow: 0, //是否关注
					ifecommend: 0, //是否推荐
					ifhot: 1 //是否热门
				}],
				circleList: []
			}
		},
		onShow() {
			//首页获取圈子列表
			this.getCircleData();
		},
		methods: {
			getCircleData() {
				let self = this;
				uni.showLoading({
					title: '加载中'
				});
				self._get('plus/circle/list', {
					keyword: self.keyword,
					iffollow: self.iffollow,
					ifecommend: self.ifecommend,
					ifhot: self.ifhot
				}, function(res) {
					let data = res.data;
					self.circleList = data.list;
					uni.hideLoading();
				})
			},
			addFollow(item) {
				let self = this;
				uni.showLoading({
					title: '加载中'
				});
				self._postBody('plus/circle/addOrDelCollect', {
					toFollow: item.id,
					userId: item.userId,
				}, function(res) {
					uni.hideLoading();
					self.getCircleData();
				});
			},
			addLikes(circleId) {
				console.log('addLikes');
				let self = this;
				uni.showLoading({
					title: '加载中'
				});
				self._postBody('plus/circle/addLikes', {
					circleId: circleId
				}, function(res) {
					uni.hideLoading();

					self.getCircleData();
				});
			},
			addDiscuss(circleId) {
				uni.navigateTo({
					url: '/pages/universe/comment?circleId=' + circleId
				});
			},
			selectCircleTab(item) {
				console.log('item===', item);
				this.iffollow = item.iffollow;
				this.ifecommend = item.ifecommend;
				this.ifhot = item.ifhot;
				//首页获取圈子列表
				this.getCircleData();
			},
			iss() {
				uni.navigateTo({
					url: '/pages/universe/issue'
				});
			},
			search() {
				this.getCircleData();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.universe {
		min-height: 100vh;
	}

	.mgb-20 {
		margin-bottom: 20rpx;
		display: flex;
		align-items: center;
	}

	.bg {
		width: 750rpx;
		height: 750rpx;
		background-image: url('../../static/b1.png');
		background-size: 100% 100%;
		margin-bottom: 17rpx;

		.bg_img {
			// padding-top: 95rpx;
			margin-left: 30rpx;
			margin-bottom: 65rpx;
			width: 240rpx;
			height: 63rpx;
		}

		.tab {
			display: flex;
			justify-content: center;
		}

		.sea {
			margin-top: 28rpx;
			margin-left: 20rpx;
			margin-right: 20rpx;
		}

		.rw {
			margin-left: 20rpx;
			margin-right: 20rpx;

			.rw_img {
				width: 100%;
				height: 340rpx;
			}
		}
	}

	.tabicon {
		width: 110rpx;
		height: 110rpx;
		margin-right: 33rpx;

		.icon_img {
			width: 100%;
			height: 100%;
			border-radius: 50%;
		}
	}

	.flx {
		// width: 100%;
		display: flex;
		align-items: center;
		margin-left: 40rpx;
		margin-right: 40rpx;
		padding-top: 46rpx;
	}

	.flx1 {
		display: flex;
	}

	.txt_fx1 {
		display: flex;
		justify-content: space-between;
		flex: 1;

		.btn {
			text-align: center;
			width: 150rpx;
			height: 22rpx;
			line-height: 22rpx;
			background: #0F4BCB;
			border-radius: 10rpx;
			font-weight: 400;
			font-size: 24rpx;
			color: #FFFFFF;
			padding: 9rpx;
			margin-left: 23rpx;
		}

		.txt {
			font-family: Source Han Sans CN;
			font-weight: 500;
			font-size: 32rpx;
			color: #000000;
		}
	}

	.sltxt {
		font-family: Source Han Sans CN;
		font-weight: 300;
		font-size: 24rpx;
		color: #999999;
		margin-right: 40rpx;
	}

	.shan {
		width: 20rpx;
		height: 20rpx;
	}

	.head {
		margin-left: 40rpx;
		margin-top: 54rpx;
		margin-right: 40rpx;
		padding-bottom: 52rpx;
		border-bottom: 1rpx solid #CCCCCC;
	}

	.headtxt {
		margin-bottom: 30rpx;
		font-family: Source Han Sans CN;
		font-weight: bold;
		font-size: 32rpx;
		color: #333333;
		line-height: 43rpx;
	}

	.nrtxt {
		font-family: Source Han Sans CN;
		font-weight: 400;
		font-size: 24rpx;
		color: #333333;
	}

	.tb {
		display: inline-block;
		width: 30rpx;
		height: 30rpx;
		vertical-align: middle;
	}

	.flx2 {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 30rpx;
	}

	.imgtb {}

	.smtxt {
		font-weight: 400;
		font-size: 24rpx;
		color: #999999;
	}

	.smtxt1 {
		font-weight: 400;
		font-size: 24rpx;
		color: #999999;
	}

	.ft {
		width: 260rpx;
		height: 240rpx;
	}

	.pos {
		position: fixed;
		right: 0;
		bottom: 200rpx;
	}

	.search {
		height: 80rpx;
		line-height: 54rpx;
		background: #F5F5F5;
		border-radius: 54rpx 54rpx 54rpx 54rpx;
		display: flex;
		align-content: center;

		.sea_ipt {
			height: 80rpx;
		}

		image {
			width: 27rpx;
			height: 27rpx;
			margin: 14rpx 10rpx 14rpx 18rpx;
		}

		input {
			height: 54rpx;
			line-height: 54rpx;
			font-size: 22rpx;
			color: #999999;
			display: flex;
			flex: 1;
			margin-right: 30rpx;
			margin-left: 30rpx;
		}

		.btn {
			width: 140rpx;
			height: 80rpx;
			line-height: 80rpx;
			background: #0F4BCB;
			border-radius: 54rpx 54rpx 54rpx 54rpx;
			text-align: center;
			font-size: 29rpx;
			font-weight: 500;
			color: #FFFFFF;
		}
	}

	.con_tu {
		width: 200rpx;
		height: 280rpx;
		margin-top: 40rpx;
		margin-left: 10rpx;
		display: inline-block;
	}
</style>